﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;

public partial class Admin_SystemCycle_QuarterDate_Add : System.Web.UI.Page
{
    QuarterDateManager dllQuarterDateManager = new QuarterDateManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindDropDownList(this.drpYeare);
        }
    }

    /// <summary>
    /// 绑定年份DropDownList
    /// </summary>
    /// <author>grokyao</author>
    /// <date>2009-1-12</date>
    void bindDropDownList(DropDownList _drp)
    {
        for (int i = 2009; i <= 2100; i++)
        {
            ListItem li = new ListItem(i.ToString());
            li.Value = i.ToString();
            _drp.Items.Add(li);
        }
        string _year = Utility.HttpHelp.getParamsString("Year");
        this.drpYeare.SelectedIndex = this.drpYeare.Items.IndexOf(this.drpYeare.Items.FindByText(_year));
    }


    /// <summary>
    /// 添加年周期按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <author>grokyao</author>
    /// <date>2009-1-12</date>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        object[] _value = new object[4];
        _value[0] = this.txtQuarterName.Text;
        _value[1] = this.drpYeare.SelectedValue;
        _value[2] = Convert.ToDateTime(this.txtStartDate.Text);
        _value[3] = Convert.ToDateTime(this.txtEndDate.Text);
        int result = dllQuarterDateManager.add(_value);
        if (result == 0)
        {
            Utility.Error.RedirectErrorPage("添加年周期未成功，请重试！");
        }
        else
        {
            Response.Redirect("SystemCycleManager.aspx");
        }
    }


    protected void btnReset_Click(object sender, EventArgs e)
    {
        this.txtStartDate.Text = "";
        this.txtQuarterName.Text = "";
        this.txtEndDate.Text = "";
    }
}
